package com.jzo2o.customer.controller.worker;

import com.jzo2o.customer.model.dto.request.BankAccountUpsertReqDTO;
import com.jzo2o.customer.model.dto.response.BankAccountResDTO;
import com.jzo2o.customer.service.IBankAccountService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import static com.jzo2o.customer.service.impl.BankAccountServiceImpl.SERVICE_PERSON_TYPE;

@RestController
@RequestMapping("/worker/bank-account")
public class WorkerBankAccountController {
    @Resource
    private IBankAccountService bankAccountService;

    @PostMapping
    @ApiOperation("添加或更新银行卡信息")
    public void addOrUpdateBankAccount(@RequestBody BankAccountUpsertReqDTO bankAccountUpsertReqDTO) {
        bankAccountUpsertReqDTO.setType(SERVICE_PERSON_TYPE);
        bankAccountService.saveOrUpdateBankAccount(bankAccountUpsertReqDTO);
    }

    @GetMapping("/currentUserBankAccount")
    @ApiOperation("获取当前用户银行卡信息")
    public BankAccountResDTO getCurrentUserBankAccount() {
        return bankAccountService.getCurrentUserBankAccount();
    }
}
